import axios from 'axios';

export const getQtClist = async () => {
  const data = await axios.get('https://52.push2.eastmoney.com/api/qt/clist/get', {
    params: {
      pn: 1,
      pz: 10000,
      po: 1,
      np: 1,
      fltt: 2,
      invt: 2,
      fid: 'f3',
      fs: 'm:0 t:6,m:0 t:80,m:1 t:2,m:1 t:23,m:0 t:81 s:2048',
      fields:
        'f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f22,f11,f62,f128,f136,f115,f152',
    },
  });

  return data?.data?.data?.diff;
};

export const getQtKlines = async (secid: string) => {
  const data = await axios.get(`https://push2his.eastmoney.com/api/qt/stock/kline/get`, {
    params: {
      secid,
      fields1: 'f1,f2,f3,f4,f5,f6',
      fields2: 'f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61',
      klt: '101',
      fqt: '1',
      end: '20500101',
      lmt: '1000000',
    },
  });

  return data?.data?.data;
};
